<?php
/*
* @Desc 前端基类
* @Auth fei
* @Date 2015-2-26
**/
namespace Act;
use \Act\Check;

class Base extends Check {
	public function __construct($setver, $RSMethod) {
		parent::__construct($server, $RSMethod);
		// debug start
        $this->assign('sidebar', $this->getTemp());
        // debug end
        // 分配菜单
        // $this->assign('sidebar', model('#User')->getSidebar());
	}

	function getTemplatePageBtns($count,$page_size,$page_offset=3){
		return '<div class="table-footer cus-clearfix">
				<div class="record">共6条记录</div>
				<div class="cus-paginate">
					<ul class="pure-paginator cus-clearfix">
					    <li><a class="pure-button prev" href="#">&#171;</a></li>
					    <li><a class="pure-button prev" href="#"><</a></li>
					    <li><a class="pure-button" href="#">1</a></li>
					    <li><a class="pure-button selected" href="#">2</a></li>
					    <li><a class="pure-button" href="#">3</a></li>
					    <li><a class="pure-button" href="#">4</a></li>
					    <li><a class="pure-button" href="#">5</a></li>
					    <li><a class="pure-button next" href="#">></a></li>
					</ul>
				</div>
			</div>
				';
	}
	/**
	 * 设置公共的头导航和子导航
	 * @param [type] $headerTitle 子页面标题
	 * @param [type] $subNav      子导航
	 * @param [type] $topNavSelectIndex     头部导航哪个选中:注：以0开始
	 * @param [type] $leftMenuSelectIndex   右边导航哪个选中:注：以0开始
	 * 
	 */
	function setTemplateNav($headerTitle='',$subNav=null,$topNavSelectIndex=0,$leftMenuSelectIndex=0){
		/*数据格式参考
		[
			'topNav'=>[
				['title'=>'数据管理','url'=>'#','active'=>true],
				['title'=>'账户管理','url'=>'#']
			],
			'headerTitle'=>'我是标题',
			'subNav'=>[
				['title'=>'子导航1','url'=>'#'],
				['title'=>'子导航2','url'=>'#','active'=>true],
				['title'=>'子导航3','url'=>'#']
			]
		 */
		$topNav=[
			['title'=>'数据管理','url'=>'#','active'=>false],
			['title'=>'账户管理','url'=>'#','active'=>false]
		];
		if(isset($topNav[$topNavSelectIndex])) $topNav[$topNavSelectIndex]['active']=true;
		$this->assign('pubData',[
			'topNav'=>$topNav,
			'headerTitle'=>$headerTitle,
			'subNav'=>$subNav
		]);
	}

	private function getTemp() {
		$temp = [
            1 => [
                'module_name' => '菜单管理',
                'menu_list'   => [
                                    [
                                        'menu_name'        => '后台菜单',
                                        'menu_url'         => '/menus/adminMenuList',
                                    ],
                                    [
                                        'menu_name' => '商户菜单',
                                        'menu_url' => '/menus/userMenuList',
                                    ]
                                ]
            ],
            2 => [
                'module_name' => '商户管理',
                'menu_list'   => [
                                    [
                                        'menu_name'        => '商户管理',
                                        'menu_url'         => '/Template?tpl=storeMgr.php',
                                    ],
                                    [
                                        'menu_name' => '商户分组',
                                        'menu_url' => '/Template?tpl=grouping.php',
                                    ]
                                ]
            ],
            3 => [
                'module_name' => '交易管理',
                'menu_list'   => [
                                    [
                                        'menu_name'        => '订单查询',
                                        'menu_url'         => '/Template?tpl=orderQuery.php',
                                    ],
                                ]
            ],
            4 => [
                'module_name' => '支付管理',
                'menu_list'   => [
                                    [
                                        'menu_name'        => '支付方式配置',
                                        'menu_url'         => '/Template?tpl=payConfig.php',
                                    ],
                                ]
            ],
            5 => [
                'module_name' => '财务管理',
                'menu_list'   => [
                                    [
                                        'menu_name'        => '提现管理',
                                        'menu_url'         => '/Finance/Cashing',
                                    ],
                                    [
                                        'menu_name'        => '结算管理',
                                        'menu_url'         => '/Template?tpl=denominate.php',
                                    ],
                                ]
            ]
        ];
        return $temp;
	}
}